<template>
  <div>
    <treeData v-for="item in nodes"
              :key="item.md_id"
              :item="item"></treeData>
  </div>
</template>
<script>
import data2 from "@/assets/data2.json";
import treeData from "./treeData";
import EventBus from "@/utils/EventBus";
export default {
  components: {
    treeData
  },
  data() {
    return {
      nodes: []
    }
  },
  created() {
    this.nodes = data2
  },
  methods: {
    addItem() {
      let item = {
        "md_id": "top2",
        "md_title": "三桥啊",
        "md_tier": "0",
        "md_show": false
      }
      this.nodes.push(item)
    }
  },
  mounted() {
    EventBus.$on("addItem", () => {
      this.addItem()
    })
  }
}
</script>
<style   scoped>
</style>